<template>
  <div class="goodsItem" @click="itemClick">
    <img :src="showImage" />
    <div class="goods-info">
      <p>{{ goodsItem.title }}</p>
      <span class="price">￥{{ goodsItem.price }}</span>
      <span class="collect">{{ goodsItem.cfav }}</span>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    goodsItem: Object
  },
  computed: {
    showImage() {
      return this.goodsItem.image || this.goodsItem.show.img
    }
  },
  methods: {
    itemClick() {
      this.$router.push('/detail/' + this.goodsItem.iid)
    }
  }
}
</script>

<style scoped>
.goodsItem {
  width: 48%;
  margin-left: 6px;
  position: relative;
  margin-bottom: 5px;
}
.goodsItem img {
  width: 100%;
  border-radius: 5px;
  border: 3px solid #f6f6f6;
}

.goods-info {
  font-size: 12px;
}
.goods-info p {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 10px;
}
.goods-info .price {
  color: deeppink;
  margin-left: 30px;
}
.goods-info .collect {
  position: relative;
  margin-left: 50px;
}

.goods-info .collect::before {
  content: '';
  position: absolute;
  left: -15px;
  top: -1px;
  width: 14px;
  height: 14px;
  background: url('../../asset/collect.svg') 0 0/14px 14px;
}
</style>
